package com.atguigu.paymentdemo.service.impl;

import com.atguigu.paymentdemo.entity.CourseTeacher;
import com.atguigu.paymentdemo.exception.BaseException;
import com.atguigu.paymentdemo.mapper.CourseTeacherMapper;
import com.atguigu.paymentdemo.service.CourseInfoService;
import com.atguigu.paymentdemo.service.CourseTeacherService;
import com.atguigu.paymentdemo.util.AliyunOssUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;

/**
 * @author wulifeng
 */
@Service
@AllArgsConstructor
public class CourseTeacherServiceImpl extends ServiceImpl<CourseTeacherMapper, CourseTeacher> implements CourseTeacherService {
	private final CourseInfoService courseInfoService;

	@Override
	public boolean removeById(Serializable id) {
		//校验此讲师是否有课程 有则不允许删除
		if(!courseInfoService.getByTeacherId(Long.parseLong(id.toString())).isEmpty()){
			throw new BaseException("此讲师仍有课程存在，无法删除");
		}
		return super.removeById(id);
	}
}
